# Contributor: Kevin Daudt <kdaudt@alpinelinux.org>
# Maintainer: Kevin Daudt <kdaudt@alpinelinux.org>
pkgname=postsrsd
pkgver=1.11
pkgrel=0
pkgdesc="Postfix Sender Rewriting Scheme daemon"
url="https://github.com/roehling/postsrsd"
arch="all"
license="GPL-2.0-or-later AND ( GPL-2.0-only OR BSD-3-Clause )"
makedepends="cmake help2man"
pkgusers="postsrsd"
install="$pkgname.pre-install"
subpackages="$pkgname-doc $pkgname-openrc"
source="$pkgname-$pkgver.tar.gz::https://github.com/roehling/postsrsd/archive/$pkgver.tar.gz
	10-fix-defaults.patch
	postsrsd.initd
	"

# secfixes:
#   1.6-r4:
#     - CVE-2020-35573

build() {
	cmake -B build -DCMAKE_INSTALL_PREFIX=/usr/ \
		-DCMAKE_BUILD_TYPE=None \
		-DGENERATE_SRS_SECRET=OFF \
		-DCONFIG_DIR=/etc/postsrsd
	make -C build all
}

check() {
	build/postsrsd_tests
}

package() {
	make -C build DESTDIR="$pkgdir/" install

	install -d "$pkgdir/etc/postsrsd/"
	install -Dm0644 build/postsrsd.default "$pkgdir/etc/conf.d/postsrsd"
	install -Dm0755 "$srcdir/postsrsd.initd" "$pkgdir/etc/init.d/postsrsd"
}

sha512sums="cc041bbbd0277dd416a19e427d63eace3489dc518ebe3a61a022b3e2e159bcb09731a0eb5547eb85bd55887821726b66e828326c109c2ebe26b27dbd062a8d89  postsrsd-1.11.tar.gz
96a1c4e04ded844b98e5b5e263af51389ad8f1424a0fcd923f8156a2f9491b67552fbe3b5ad972cf1279d7b0e022787d151b5151a27da43227176356848ec4d7  10-fix-defaults.patch
8541fbd517370cabf905b992ba4aeccc249c56b71bf0c3f5f50c13a4bbc9e191265632147d9f2cd617911049144abbf0f2c510d0fa41ba4268ccf1ede9798116  postsrsd.initd"
